package com.itbaizhan.listener;

import javax.servlet.ServletRequestAttributeEvent;
import javax.servlet.ServletRequestAttributeListener;
import javax.servlet.annotation.WebListener;

/*HttpServletRequest属性监听器
* 1,创建完监听器，在wed.xml 配置<listener>中的<listener-class>  或：注解式开发@WebListener  不用配置参数，
* 因为只有listener-class，容器会自动找到地址*/
@WebListener
public class HttpServletRequestAttrListener implements ServletRequestAttributeListener {
    @Override
    public void attributeAdded(ServletRequestAttributeEvent srae) {
        System.out.println("------start Added------");
        System.out.println("name: "+srae.getName()+" value: "+srae.getValue());
        System.out.println(srae.getServletRequest());
        System.out.println("------end Added-------");
    }

    @Override
    public void attributeRemoved(ServletRequestAttributeEvent srae) {
        System.out.println("------start remove------");
        System.out.println("name: "+srae.getName()+" value: "+srae.getValue());
        System.out.println(srae.getServletRequest());
        System.out.println("------end remove-------");
    }

    @Override
    public void attributeReplaced(ServletRequestAttributeEvent srae) {
        System.out.println("------start Replace------");
        System.out.println("name: "+srae.getName()+" value: "+srae.getValue());
        System.out.println(srae.getServletRequest());
        System.out.println("------end Replace-------");
    }
}
